SetStyle
The text style base method. 💡 This method is not used by itself, as it only forms the basis for the {@link ApiRun#SetStyle} method which sets the selected or created style to the text.
Syntax
expression.SetStyle(oStyle);
expression
- A variable that represents a ApiRun class.
Parameters
Name | Required/Optional | Data type | Default | Description |
---|---|---|---|---|
oStyle | Required | ApiStyle | The style which must be applied to the text character. |
Returns
Example
This example sets a style to run.
let doc = Api.GetDocument();
let myNewRunStyle = doc.CreateStyle("My New Run Style", "run");
let textPr = myNewRunStyle.GetTextPr();
textPr.SetCaps(true);
textPr.SetFontFamily("Calibri Light");
let paragraph = doc.GetElement(0);
let run = Api.CreateRun();
run.AddText("This is just a sample text. ");
run.AddText("The text properties are changed and the style is added to the paragraph. ");
paragraph.AddElement(run);
run = Api.CreateRun();
run.SetStyle(myNewRunStyle);
run.AddText("This is a text run with its own style.");
paragraph.AddElement(run);